package com.doujiang.domain;

import lombok.Data;

/**
 * 验证码实体类
 */
@Data
public class VerificationCode {
    private String code;
    private long timestamp;
    private static final long EXPIRE_TIME = 5 * 60 * 1000; // 5分钟过期

    public VerificationCode(String code, long timestamp) {
        this.code = code;
        this.timestamp = timestamp;
    }

    public boolean isValid(String inputCode) {
        // 检查验证码是否匹配且未过期
        return code.equals(inputCode) && !isExpired();
    }

    public boolean isExpired() {
        return System.currentTimeMillis() - timestamp > EXPIRE_TIME;
    }
} 